package com.feilong.modules.model.goods.response;

import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.feilong.modules.common.result.WxCloudRestCode;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class WxCloudResponse<T> implements Serializable {

    /**
     * 错误码
     */
    private Integer errcode;

    /**
     * 错误信息
     */
    private String errmsg;

    /**
     * 返回数据
     */
    private T data;

    @JSONField(serialize = false, deserialize = false)
    @JsonIgnore
    public final WxCloudResponse<T> HYSTRIX_ERROR = hystrixError();

    private WxCloudResponse<T> hystrixError() {
        this.errcode = -3;
        this.errmsg = WxCloudRestCode.SYSTEM_ERROR.getMsg();
        return this;
    }
}
